<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Countdown to NCEE</title>
        <link rel="stylesheet" href="homework3 exam2.css">
    </head>
    <body>
        <div class="container">
             <h2><span>Countdown to NETEM</span> 2022</h2>
             <div class="countdown">
                 <div id="day">NA</div>
                 <div id="hour">NA</div>
                 <div id="minute">NA</div>
                 <div id="second">NA</div>
             </div>
         </div>

    </body>
</html>
<script type="text/javascript">
// type是默认值，意思是js

    function getEndTime(myYear){
        var myEndTime = new Date(''+myYear+'/12/24 00:00:00');
        return myEndTime;
    }

    function countDown(){
        var mydate = new Date();
        // 获取当前时间
        var year = '2020';
        var EndTime = getEndTime(year);
        var NowTime = new Date();
        while( EndTime.getTime() < NowTime.getTime() ){
            year++;
            EndTime = getEndTime(year);
        }
        var t = EndTime.getTime() - NowTime.getTime();

        var d=Math.floor(t/1000/60/60/24);
        var h=Math.floor(t/1000/60/60%24);
        var m=Math.floor(t/1000/60%60);
        var s=Math.floor(t/1000%60);
        // 弄出相应的各个时间值

        document.getElementById('day').innerText = d;
        document.getElementById('hour').innerText = h;
        document.getElementById('minute').innerText = m;
        document.getElementById('second').innerText = s;
    } 
    setInterval(countDown,1000);
    // 不断调用函数
</script>
